"""
行为树黑板: 记录变量 拥有者读写过程
"""

import py_trees

if __name__ == "__main__":
    # 1.开启黑板日志记录
    py_trees.blackboard.Blackboard.enable_activity_stream(maximum_size=100)

    # 2.存储
    reader = py_trees.blackboard.Client(name="Reader_Test")
    reader.register_key(key="foo", access=py_trees.common.Access.READ)
    writer = py_trees.blackboard.Client(name="Writer_Test")
    writer.register_key(key="foo", access=py_trees.common.Access.WRITE)
    writer.foo = "bar"
    writer.foo = "foobar"
    value1 = reader.foo
    value2 = reader.foo

    # 3.查看黑板日志
    print(py_trees.display.unicode_blackboard_activity_stream())


""" 
Blackboard Activity Stream
    /foo : INITIALISED   | Writer_Test | → bar
    /foo : WRITE         | Writer_Test | → foobar
    /foo : READ          | Reader_Test | ← foobar
    /foo : READ          | Reader_Test | ← foobar
"""